package model;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class Rect extends Shape {

    private int width;
    private int height;
    private Color fill;

    public Rect(int x, int y, int stroke, Color stroke_color, int width,
	    int height, Color fill) {
	super(x, y, stroke, stroke_color);
	this.height = height;
	this.width = width;
	this.fill = fill;
    }

    public int getWidth() {
	return width;
    }

    public void setWidth(int width) {
	this.width = width;
    }

    public int getHeight() {
	return height;
    }

    public void setHeight(int height) {
	this.height = height;
    }

    public Color getFill() {
	return fill;
    }

    public void setFill(Color fill) {
	this.fill = fill;
    }

    @Override
    public void draw(Graphics g, float zoom_scale) {

	Graphics2D g2 = (Graphics2D) g;

	// Outline
	if (getStrokeColor() != null) {
	    g2.setStroke(new BasicStroke(getStrokeWidth()));
	    g.setColor(getStrokeColor());
	    g.drawRect((int) (getX() * zoom_scale),
		    (int) (getY() * zoom_scale),
		    (int) (getWidth() * zoom_scale),
		    (int) (getHeight() * zoom_scale));
	}

	// Fill
	if (getFill() != null) {
	    g.setColor(getFill());
	    g.fillRect((int) (getX() * zoom_scale + 1), (int) (getY()
		    * zoom_scale + 1), (int) (getWidth() * zoom_scale - 1),
		    (int) (getHeight() * zoom_scale - 1));
	}
    }

}
